﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Com.Crc.PoJo.Model.Security;
using CRC.BLL.Security;

namespace CRC.Web.Account
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
        {
            string strErrmess = "";
            UserSecurityManager manager = new UserSecurityManager();
            UserEntity _user = manager.Login(Login1.UserName, Login1.Password, ref strErrmess);
            if (_user == null)
            {
                e.Authenticated = false;
                Login1.FailureText = strErrmess;

            }
            else
            {

                e.Authenticated = true;
                //Session[SessionVari.UserID] = _user.UserID;
                //Session[SessionVari.LoginName] = _user.LoginName;

                //LogEngin.AddLog(Login1.UserName, "成功", 1, Request.UserHostAddress);

                //将用户登录信息写入cookie
                //HttpCookie coLoginName = Request.Cookies[PassportCookie.LoginName];
                //if (coLoginName == null)
                //{
                //    coLoginName = new HttpCookie(PassportCookie.LoginName);
                //}
                //coLoginName.Value = Server.UrlEncode(this.Login1.UserName);
                //this.Response.Cookies.Add(coLoginName);

                Response.Redirect("~/Default.aspx", true);
            }
        }

    }
}